package edu.zut;
import java.util.*;

public class StudentDemo {
        public static void main(String[] args){
            Scanner in=new Scanner(System.in);
            int n=in.nextInt();
            StudentList L=new StudentList();
            for(int i=0;i<n;i++){
                L.add(in.nextInt(),in.next(),in.nextInt());
            }
            int m=in.nextInt();
            for(int i=0;i<m;i++){
                String test=in.next();
                if(test.equals("add")){
                    L.add(in.nextInt(),in.next(),in.nextInt());
                }else if(test.equals("delete")){
                    L.delete(in.nextInt());
                }else if(test.equals("set")){
                    L.set(in.nextInt(),in.nextInt());
                }
            }
            L.print();
        }
    }

    class Student{
        int no;
        String name;
        int score;

        public Student(int no,String name,int score){
            this.no=no;
            this.name=name;
            this.score=score;
        }

        @Override
        public String toString(){//no:1 name:wong score:90
            return "no:"+this.no+" name:"+this.name+" score:"+this.score;
        }

        @Override
        public boolean equals(Object o){
            if(o==null)return false;
            Student s=(Student)o;

            if(this.no==s.no)return true;
            else             return false;
        }

        @Override
        public int hashCode(){
            int result=11;
            result=result*31+no;
            return result;
        }
    }

    class StudentList{
        Student[] list=new Student[9999];
        int count;
        public StudentList(){
            this.count=0;
        }

        public void add(int no,String name,int score){
            Student s=new Student(no,name,score);
            list[this.count]=s;
            this.count++;
        }

        public void delete(int no){
            int loc=count;
            for(int i=0;i<count;i++){//找位置
                if(list[i].no==no){
                    loc=i;
                    break;
                }
            }

            for(int i=loc;i<=count-2;i++){//找到后依次左移即可
                list[i]=list[i+1];
            }
            list[count-1]=null;
            this.count--;//个数减减
        }

        public void set(int no,int score){
            for(int i=0;i<count;i++){
                if(list[i].no==no){
                    list[i].score=score;
                    return ;
                }
            }
            return ;
        }

        public void print(){
            for(int i=0;i<count;i++){
                System.out.println(list[i]);
            }
        }
    }
